/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package IO;

/**
 *
 * @author Eagle
 */
public class linkInfoClass {

        private int preCellId,postCellId,grpSize;
        int pre(){
            return preCellId;
        }
        int post(){
            return postCellId;
        }
        int grpSize(){
            return grpSize;
        }


    linkInfoClass(int link, int dgrp, int tgrp, int qgrp){

        if (link<dgrp*2){
            preCellId=link;
            switch (link%2) {
                case 1:
                    postCellId=--link;
                    break;
                case 0:
                    postCellId=++link;
                    break;
            }
            grpSize=2;
        }
        else if (link<dgrp*2+tgrp*6){
            int cellsn=link-dgrp*2;
            int postkey=cellsn;
            cellsn=(int) Math.floor(cellsn/2);
            cellsn+=dgrp*2;
            preCellId=cellsn;
            switch (postkey%6) {
                case 0:
                case 3:
                    postCellId=++cellsn;
                    break;
                case 2:
                case 5:
                    postCellId=--cellsn;
                    break;
                case 1:
                    postCellId=cellsn+2;
                    break;
                case 4:
                    postCellId=cellsn-2;
                    break;
            }
            grpSize=3;
        }
        else {
            int cellsn=link-dgrp*2-tgrp*6;
            int postkey=cellsn;
            cellsn=(int) Math.floor(cellsn/3);
            cellsn+=dgrp*2+tgrp*3;
            preCellId=cellsn;
            switch (postkey%12) {
                case 0:
                case 4:
                case 8:
                    postCellId=++cellsn;
                    break;
                case 1:
                case 5:
                    postCellId=cellsn+2;
                    break;
                case 2:
                    postCellId=cellsn+3;
                    break;
                case 3:
                case 7:
                case 11:
                    postCellId=--cellsn;
                    break;
                case 6:
                case 10:
                    postCellId=cellsn-2;
                    break;
                case 9:
                    postCellId=cellsn-3;
                    break;
            }
            grpSize=4;
            
        }
    }



}
